<!DOCTYPE HTML>
<html>
<head>
    <title>钱包管理</title>
    <link rel="stylesheet" href="/stylesheets/style.css">
    <script src="/scripts/jquery.min.js"></script>
    <link rel="stylesheet" href="/scripts/miniui/themes/default/miniui.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/icons.css">
    <link rel="stylesheet" href="/editor/common.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/bootstrap/skin.css">
    <script src="/scripts/miniui/miniui.js"></script>
</head>
<body  style="padding: 0;width: 100%;height: 100%">
<div  style="width:100%;height:97%;">
    <div showCollapseButton="true" style="height: 98%">
        <div style="width:99%;">
            <div class="mini-toolbar" style="border-bottom:0;padding:0px;">
                <table style="width:100%;">
                    <tr>
                        <td style="width:100%;">
                            <a class="mini-button" iconCls="icon-add" onclick="add()">增加</a>
                            <a class="mini-button" iconCls="icon-remove" onclick="remove()">删除</a>
                            <a class="mini-button" iconCls="icon-edit" onclick="getDealList()">查看交易</a>
                            <a class="mini-button" iconCls="icon-edit" onclick="distributeToken()">发币</a>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        <div id="datagrid1" class="mini-datagrid" style="width:99%;height: 96%;"
             url="/getdata/getWalletInfo" idField="id" allowResize="true"
             sizeList="[20,30,50,100]" pageSize="30"
        >
            <div property="columns">
                <div type="checkcolumn" width="10"></div>
                <div field="objectId" width="60" align="center" headerAlign="center" >objectId</div>
                <div field="userOId"  width="60" align="center" headerAlign="center" >用户ID</div>
                <div field="nickName" width="30" align="center" headerAlign="center" >用户名称</div>
                <div field="tokenType" width="15" align="center" headerAlign="center" >币种</div>
                <div field="walletAddress" width="150" align="center" headerAlign="center" >钱包地址</div>
                <div field="createdAt" width="50" align="center" headerAlign="center" >创建时间</div>
                <div field="updatedAt" width="50" align="center" headerAlign="center" >更新时间</div>
            </div>
        </div>
    </div>
</div>
</body>
<script type="text/javascript">
  var flag = 1;
  mini.parse();
  var grid = mini.get("datagrid1");
  grid.load();
  grid.on("drawcell", function (e) {
    var  value = e.value;
  });

  function add() {
    mini.open({
      url: "/getdata/addWalletAddress",
      title: "增加地址", width: 400, height: 260,
      ondestroy: function (action) {
        grid.reload();
      }
    });
  };
  function remove() {
    var row = grid.getSelected();
    if (row) {
      $.ajax({
        url:"/getdata/walletAddressRemove",
        type:'POST',
        data:{
          objectId:row.objectId
        },
        success:function (result) {
          if (result){
            alert('钱包地址删除成功！')
          } else {
            alert('钱包地址删除失败！')
          }
          grid.reload();
        }
      });
    } else {
      alert("请选中一条记录");
    }
  };

  function distributeToken() {
    var row = grid.getSelected();
    if (row) {
      mini.open({
        url: "/getdata/showDistributeTokenInfo?id=" + row.objectId,
        title: "发币", width: 400, height: 500,
        ondestroy: function (action) {
          grid.reload();
        }
      });
    } else {
      alert("请选中一条记录");
    }
  };

  function getDealList() {
    var row = grid.getSelected();
    if (row) {
      mini.open({
        url: "/getdata/showQueryAddressPageTx?walletAddress=" + row.walletAddress,
        title: "查看交易", width: 1000, height: 600,
        ondestroy: function (action) {
          grid.reload();
        }
      });
    } else {
      alert("请选中一条记录");
    }
  };

</script>
</html>